
import java.util.Scanner;

// 微信红包
public class Main {
    public static int getValue(int[] gifts, int n) {
        // write code here
        int times = 1;
        int result = gifts[0];
        for (int i = 1; i < n; ++i) {
            if (times == 0) {
                result = gifts[i];
                times = 1;
            } else if(gifts[i] == result) {
                times++;
            } else {
                times--;
            }
        }
        int count = 0;
        for (int i = 0; i < n; ++i) {
            if(gifts[i] == result)
                count++;
        }
        return count > n / 2 ? result : 0;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] array = { 1,2,3,2,2 };
        int n = 5;
        System.out.println(getValue(array,n));
    }
}
